﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace QLThuVien
{
    public class NhanVien
    {
        string MaNV, HotenNV, DiaChi, QuyenHan, TenDN, MatKhau;
        public NhanVien()
        { }
        public NhanVien(string MaNV, string HotenNV, string DiaChi, string QuyenHan, string TenDN, string MatKhau)
        {
            this.MaNV = MaNV;
            this.HotenNV = HotenNV;
            this.DiaChi = DiaChi;
            this.QuyenHan = QuyenHan;
            this.TenDN = TenDN;
            this.MatKhau = MatKhau;
        }
        #region cac thu tuc Set
        public void set_MaNV(string MaNV)
        {
            this.MaNV = MaNV;
        }
        public void set_hotenNV(string hotenNV)
        {
            this.HotenNV = hotenNV;
        }
        public void set_diachi(string diachi)
        {
            this.DiaChi = diachi;
        }
        public void set_QuyenHan(string quyenhan)
        {
            this.QuyenHan = quyenhan;
        }
        public void set_tenDN(string tendangnhap)
        {
            this.TenDN = tendangnhap;
        }
        public void set_MatKhau(string matkhau)
        {
            this.MatKhau = matkhau;
        }
        #endregion
        #region cac thu tuc get
        public string get_MaNV()
        {
            return MaNV;
        }
        public string get_HotenNV()
        {
            return HotenNV;
        }
        public string get_DiaChi()
        {
            return DiaChi;
        }
        public string get_QuyenHan()
        {
            return QuyenHan;
        }
        public string get_TenDN()
        {
            return TenDN;
        }
        public string get_MatKhau()
        {
            return MatKhau;
        }
        #endregion
        #region cac phuong thuc hoat dong
        public bool taomoi()
        {
            Truyxuatdulieu txdl = new Truyxuatdulieu();
            if (txdl.thucthitruyvan(" insert into Nhanvien values ('" + MaNV + "',N'" + HotenNV + "',N'" + DiaChi + "',N'" + TenDN + "','" + MatKhau + "','" + QuyenHan + "')") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else return false;
        }
        public bool nangquyen(string quyenmoi)
        {
            this.QuyenHan = quyenmoi;
            Truyxuatdulieu ld = new Truyxuatdulieu();
            if (ld.thucthitruyvan(" update Nhanvien set quyenhan ='" + quyenmoi + "' where manhanvien = '" + MaNV + "'") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else return false;
        }
        public bool capnhat()
        {
            Truyxuatdulieu ld = new Truyxuatdulieu();
            if (ld.thucthitruyvan(" update Nhanvien set hoten=N'" + HotenNV + "',diachi=N'" + DiaChi + "',tendangnhap=N'" + TenDN + "',matkhau=N'" + MatKhau + "' where manhanvien='" + MaNV + "'") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else return false;
        }
        public bool doimatkhau(string moi)
        {
            Truyxuatdulieu ld = new Truyxuatdulieu();
            MatKhau = moi;
            if (ld.thucthitruyvan(" update Nhanvien set matkhau=N'" + moi + "' where manhanvien='" + MaNV + "'") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else return false;
        }
        public bool xoabo()
        {
            Truyxuatdulieu ld = new Truyxuatdulieu();
            if (ld.thucthitruyvan(" delete from Nhanvien where manhanvien= '" + MaNV + "'") == 1)
            {
                KetNoi.closeconnect();
                return true;
            }
            else return false;
        }
        #endregion    
    }
}
